package leraning.httpUrlConnection;

import java.net.HttpURLConnection;
import java.net.URL;

public class HttpURLConnection2 {
	public static void main(String[] args) {
		URL url = null;
		String username="admin";
		String psw="admin";
		String path="http://10.6.156.74:8080/Day28_web/LoginServlet?username="+username+"&password="+psw;
		try {
			url = new URL(
					path);
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//			if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
//				System.out.println("request successfully");
//				InputStream is=conn.getInputStream();
//				OutputStream os=conn.getOutputStream();
//				System.out.println(conn.getDoInput());
//				System.out.println(conn.getDoOutput());
//				conn.setDoOutput(true);
//				os.flush();
//				is.close();
//				os.close();
//				conn.disconnect();
				System.out.println(conn.getResponseCode());
//			} else
//				System.out.println("request error");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
